﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument
{
    class Class4
    {
        public static void Standard29014_3_E4(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            double ls = 40;
            double lcf = 49.5;
            double d1 = 20;
            double d2 = 25;
            double l1 = 7;
            double l2 = 26;
            double ps = 2 * pi / 180;
            string path = Convert.ToString(data["path"]);

            //坐标
            Vector2 v0 = new Vector2(0, 0);
            Vector2 v1 = new Vector2(v0.X, v0.Y + d1 / 2 - 1);
            Vector2 v2 = new Vector2(v1.X - 1, v1.Y + 1);
            Vector2 v3 = new Vector2(v2.X - 11, v2.Y);
            Vector2 v4 = new Vector2(v3.X, v3.Y - 0.5);
            Vector2 v5 = new Vector2(v4.X - 16, v4.Y);
            Vector2 v6 = new Vector2(v5.X, v5.Y + 0.5);
            Vector2 v7 = new Vector2(v6.X - 11, v6.Y);
            Vector2 v8 = new Vector2(v0.X - ls, v0.Y + d2 / 2);
            Vector2 v9 = new Vector2(v8.X, v0.Y - d2 / 2);
            Vector2 v10 = new Vector2(v7.X, v7.Y - d1);
            Vector2 v11 = new Vector2(v6.X, v6.Y - d1);
            Vector2 v12 = new Vector2(v11.X, v11.Y + 0.5);
            Vector2 v13 = new Vector2(v4.X, v12.Y);
            Vector2 v14 = new Vector2(v13.X, v11.Y);
            Vector2 v15 = new Vector2(v2.X, v14.Y);
            Vector2 v16 = new Vector2(v1.X, v0.Y - d1 / 2 + 1);
            Vector2 v17 = new Vector2(v0.X - l1, v0.Y + 3);
            Vector2 v18 = new Vector2(v17.X - l2, v17.Y + Math.Sin(ps) * l2);
            Vector2 v19 = new Vector2(v17.X, v0.Y - 6);
            Vector2 v20 = new Vector2(v18.X, v19.Y - Math.Sin(ps) * l2);
            Vector2 v21 = new Vector2(v4.X, v17.Y + Math.Sin(ps) * 5);
            Vector2 v22 = new Vector2(v5.X, v17.Y + Math.Sin(ps) * 21);
            Vector2 v23 = new Vector2(v4.X, v19.Y - Math.Sin(ps) * 5);
            Vector2 v24 = new Vector2(v5.X, v19.Y - Math.Sin(ps) * 21);
            Vector2 v25 = new Vector2(v7.X - 1, v7.Y);
            Vector2 v26 = new Vector2(v25.X, v10.Y);
            Vector2 v27 = new Vector2(v8.X - 5, v8.Y);
            Vector2 v28 = new Vector2(v27.X, v9.Y);
            Vector2 v29 = new Vector2(v28.X - 2, v0.Y - 8);
            Vector2 v30 = new Vector2(v29.X, v0.Y + 8);
            Vector2 v31 = new Vector2(v30.X - 1.5, v30.Y);
            Vector2 v32 = new Vector2(v30.X - 5.5, v0.Y + 1.75);
            Vector2 v33 = new Vector2(v32.X, v0.Y + 0.25);
            Vector2 v34 = new Vector2(v31.X - 42.8, v31.Y);
            Vector2 v35 = new Vector2(v34.X - 4.46 * Math.Cos(25 * pi / 180), v34.Y + 4.46 * Math.Sin(25 * pi / 180));
            Vector2 v36 = new Vector2(v35.X - Math.Sin(15 * pi / 180) * 4.46, v35.Y - Math.Cos(15 * pi / 180) * 4.46);
            Vector2 v37 = new Vector2(v36.X + Math.Sin(5 * pi / 180) * 4.46, v36.Y - Math.Cos(5 * pi / 180) * 4.46);
            Vector2 v38 = new Vector2(v37.X + Math.Cos(15 * pi / 180) * 4.46, v37.Y + Math.Sin(15 * pi / 180) * 4.46);
            Vector2 v39 = new Vector2(v38.X + Math.Cos(35 * pi / 180) * 4.46, v38.Y + Math.Sin(35 * pi / 180) * 4.46);
            Vector2 v40 = new Vector2(v37.X + 3.26, v37.Y + Math.Tan(15 * pi / 180) * 3.26 + 3.26 / Math.Cos(15 * pi / 180));
            Vector2 v41 = new Vector2(v32.X - lcf * 36.5 / 49.5, v32.Y);
            Vector2 v42 = new Vector2(v41.X + Math.Cos(45 * pi / 180) * 1.5, v41.Y - Math.Sin(45 * pi / 180) * 1.5);
            Vector2 v43 = new Vector2(v41.X + Math.Tan(45 * pi / 180) * 1.5, v33.Y);
            Vector2 v44 = new Vector2(v41.X - lcf * 6.1 / 49.5, v41.Y - Math.Tan(10 * pi / 180) * lcf * 6.1 / 49.5);
            Vector2 v45 = new Vector2(v44.X - lcf * 0.35 / 49.5, v44.Y - lcf * 0.35 / 49.5 / Math.Tan(15 * pi / 180));
            Vector2 v46 = new Vector2(v45.X - lcf * 0.62 / 49.5, v45.Y - lcf * 0.62 / 49.5 / Math.Tan(15 * pi / 180));
            Vector2 v47 = new Vector2(v46.X + lcf * 1.19 / 49.5, v46.Y - lcf * 1.19 / 49.5 / Math.Tan(15 * pi / 180));//
            Vector2 v48 = new Vector2(v29.X - lcf * 47.66 / 49.5, v29.Y);
            Vector2 v49 = new Vector2(v48.X - lcf * 0.63 / 49.5, v48.Y + lcf * 0.63 / 49.5 * Math.Tan(38 * pi / 180));
            Vector2 v50 = new Vector2(v30.X - lcf, v46.Y);
            Vector2 v51 = new Vector2(v50.X + lcf * 0.83 / 49.5, v50.Y + lcf * 0.83 / 49.5 / Math.Tan(15 * pi / 180));
            Vector2 v52 = new Vector2(v51.X + lcf * 0.4 / 49.5, v51.Y - lcf * 0.4 / 49.5 * Math.Tan(15 * pi / 180));
            Vector2 v53 = new Vector2(v44.X, v44.Y + 0.7);
            Vector2 v54 = new Vector2(v39.X - 0.5 * Math.Sin(45 * pi / 180), v39.Y + 0.5 * Math.Cos(45 * pi / 180));
            Vector2 v55 = new Vector2(v39.X - Math.Cos(35 * pi / 180) * 0.5, v39.Y - Math.Sin(35 * pi / 180) * 0.5);
            Vector2 v56 = new Vector2(v0.X + 5, v0.Y);
            Vector2 v57 = new Vector2(v0.X - 101.5, v0.Y);
            //作图
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(v1));
            poly1.Vertexes.Add(new LwPolylineVertex(v2));
            poly1.Vertexes.Add(new LwPolylineVertex(v3));
            poly1.Vertexes.Add(new LwPolylineVertex(v4));
            poly1.Vertexes.Add(new LwPolylineVertex(v5));
            poly1.Vertexes.Add(new LwPolylineVertex(v6));
            poly1.Vertexes.Add(new LwPolylineVertex(v7));
            poly1.Vertexes.Add(new LwPolylineVertex(v10));
            poly1.Vertexes.Add(new LwPolylineVertex(v11));
            poly1.Vertexes.Add(new LwPolylineVertex(v12));
            poly1.Vertexes.Add(new LwPolylineVertex(v13));
            poly1.Vertexes.Add(new LwPolylineVertex(v14));
            poly1.Vertexes.Add(new LwPolylineVertex(v15));
            poly1.Vertexes.Add(new LwPolylineVertex(v16));
            poly1.Vertexes.Add(new LwPolylineVertex(v1));
            fun.PolyFill(dxf, poly1, 0.3, contour);
            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(v17));
            poly2.Vertexes.Add(new LwPolylineVertex(v18));
            poly2.Vertexes.Add(new LwPolylineVertex(v20));
            poly2.Vertexes.Add(new LwPolylineVertex(v19));
            poly2.Vertexes.Add(new LwPolylineVertex(v17));
            fun.PolyFill(dxf, poly2, 0.3, contour);
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(v8));
            poly3.Vertexes.Add(new LwPolylineVertex(v27));
            poly3.Vertexes.Add(new LwPolylineVertex(v30));
            poly3.Vertexes.Add(new LwPolylineVertex(v29));
            poly3.Vertexes.Add(new LwPolylineVertex(v28));
            poly3.Vertexes.Add(new LwPolylineVertex(v9));
            poly3.Vertexes.Add(new LwPolylineVertex(v8));
            fun.PolyFill(dxf, poly3, 0.3, contour);
            Vector2[] Line1 = { v4, v21 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v5, v22 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v24, v12 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v13, v23 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v27, v28 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v30, v34 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(v34));
            poly4.Vertexes.Add(new LwPolylineVertex(v35));
            poly4.Vertexes.Add(new LwPolylineVertex(v36));
            poly4.Vertexes.Add(new LwPolylineVertex(v37));
            poly4.Vertexes.Add(new LwPolylineVertex(v38));
            poly4.Vertexes.Add(new LwPolylineVertex(v39));
            poly4.Vertexes.Add(new LwPolylineVertex(v34));
            fun.PolyFill(dxf, poly4, 0.3, contour);
            Vector2[] Line7 = { v53, v44 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v41, v44 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v41, v32 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v33, v43 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v43, v41 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v42, v45 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v46, v44 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v46, v48 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v48, v29 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v49, v47 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v50, v49 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v51, v50 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v51, v52 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v32));
            Arc1.Vertexes.Add(new LwPolylineVertex(v31));
            Arc1.Vertexes[0].Bulge = 45 * pi / 180 / 4;
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v33));
            Arc2.Vertexes.Add(new LwPolylineVertex(v30));
            Arc2.Vertexes[0].Bulge = 45 * pi / 180 / 4;
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            LwPolyline Arc3 = new LwPolyline();
            Arc3.Vertexes.Add(new LwPolylineVertex(v55));
            Arc3.Vertexes.Add(new LwPolylineVertex(v54));
            Arc3.Vertexes[0].Bulge = 280 * pi / 180;
            fun.PolyFill(dxf, Arc3, 0.3, contour);
            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(fun.Polar(v40, 0, 2)));
            poly.Vertexes[0].Bulge = Math.Tan(Math.PI / 4);
            poly.Vertexes.Add(new LwPolylineVertex(fun.Polar(v40, Math.PI, 2)));
            poly.Vertexes[1].Bulge = Math.Tan(Math.PI / 4);
            poly.Vertexes.Add(new LwPolylineVertex(fun.Polar(v40, 0, 2)));
            fun.PolyFill(dxf, poly, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v25));
            Arc4.Vertexes.Add(new LwPolylineVertex(v7));
            Arc4.Vertexes[0].Bulge = Math.Tan(Math.PI / 4);
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            LwPolyline Arc5 = new LwPolyline();
            Arc5.Vertexes.Add(new LwPolylineVertex(v10));
            Arc5.Vertexes.Add(new LwPolylineVertex(v26));
            Arc5.Vertexes[0].Bulge = Math.Tan(Math.PI / 4);
            fun.PolyFill(dxf, Arc5, 0.3, contour);
            Line line1 = new Line(v56, v57);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.Center;
            dxf.AddEntity(line1);

            //图二
            Vector2 a1 = new Vector2(v0.X + 30, v0.Y);
            Vector2 a2 = new Vector2(a1.X - Math.Cos(30 * pi / 180) * d2 / 2, a1.Y + Math.Sin(30 * pi / 180) * d2 / 2);
            Vector2 a3 = new Vector2(a1.X - Math.Sin(10 * pi / 180) * d2 / 2, a1.Y + Math.Cos(10 * pi / 180) * d2 / 2);
            Vector2 a4 = new Vector2(a1.X - Math.Cos(30 * pi / 180) * 8, a1.Y + Math.Sin(30 * pi / 180) * 8);
            Vector2 a5 = new Vector2(a1.X, a1.Y + 7);
            Vector2 a6 = new Vector2(a1.X, a1.Y + 0.5);
            Vector2 a7 = new Vector2(a1.X - 2, a6.Y);
            Vector2 a8 = new Vector2(a1.X - Math.Sin(17 * pi / 180) * 7, a1.Y + Math.Cos(17 * pi / 180) * 7);
            Vector2 a9 = new Vector2(a1.X, a1.Y - 7);
            Vector2 a10 = new Vector2(a1.X, a1.Y + 0.25);
            Vector2 a11 = new Vector2(a1.X + 2, a10.Y);
            Vector2 a12 = new Vector2(a1.X + Math.Sin(16 * pi / 180) * 7, a1.Y - Math.Cos(16 * pi / 180) * 7);
            Vector2 a13 = new Vector2(a1.X + 7, a1.Y);
            Vector2 a14 = new Vector2(a1.X, a1.Y + 7 * Math.Tan(9 * pi / 180));
            Vector2 a15 = new Vector2(a1.X, a11.Y + 2 * Math.Tan(9 * pi / 180));
            Vector2 a16 = new Vector2(a1.X + Math.Cos(4 * pi / 180) * 7, a1.Y - Math.Sin(4 * pi / 180) * 7);
            Vector2 a17 = new Vector2(a10.X - Math.Cos(7 * pi / 180) * 6.96, a10.Y + Math.Sin(7 * pi / 180) * 6.96);
            Vector2 a18 = new Vector2(a1.X, a1.Y - 1.75);
            Vector2 a19 = new Vector2(a18.X - Math.Cos(7 * pi / 180) * 6.96, a18.Y + Math.Sin(7 * pi / 180) * 6.96);
            Vector2 a20 = new Vector2(a1.X, a1.Y - 2.25);
            Vector2 a21 = new Vector2(a20.X - Math.Cos(15 * pi / 180) * 1.5, a20.Y + Math.Sin(18 * pi / 180) * 1.5);
            Vector2 a22 = new Vector2(a21.X - Math.Cos(15 * pi / 180) * 5, a21.Y - Math.Sin(15 * pi / 180) * 5);
            Vector2 a23 = new Vector2(a1.X - 3, a1.Y + 1.5);
            Vector2 a24 = new Vector2(a1.X + 3, a1.Y - 5.75);
            Vector2 a25 = new Vector2(a1.X + Math.Cos(10 * pi / 180) * 8, a1.Y + Math.Sin(10 * pi / 180) * 8);
            Vector2 a26 = new Vector2(a1.X + Math.Sin(17 * pi / 180) * 8, a1.Y - Math.Cos(17 * pi / 180) * 8);
            Vector2 a27 = new Vector2(a1.X + Math.Cos(3 * pi / 180) * 8, a1.Y - Math.Sin(3 * pi / 180) * 8);
            Vector2 a28 = new Vector2(a1.X + Math.Sin(30 * pi / 180) * 8, a1.Y - Math.Cos(30 * pi / 180) * 8);
            Vector2 a29 = new Vector2(a1.X - 14, a1.Y);
            Vector2 a30 = new Vector2(a1.X + 14, a1.Y);
            Vector2 a31 = new Vector2(a1.X, a1.Y + 14);
            Vector2 a32 = new Vector2(a1.X, a1.Y - 14);
            Vector2 a33 = new Vector2(a1.X, a1.Y + 12.5);
            //作图
            Circle circle1 = new Circle(a1, 7);
            circle1.Layer = contour;
            circle1.Lineweight = Lineweight.W50;
            dxf.AddEntity(circle1);
            Circle circle2 = new Circle(a1, 8);
            circle2.Layer = contour;
            circle2.Lineweight = Lineweight.W50;
            dxf.AddEntity(circle2);
            Arc arc1 = new Arc(a1, d2 / 2, 150, 100);
            arc1.Layer = contour;
            arc1.Lineweight = Lineweight.W50;
            dxf.AddEntity(arc1);
            Line line20 = new Line(a2, a4);
            line20.Layer = contour;
            line20.Lineweight = Lineweight.W50;
            dxf.AddEntity(line20);
            Line line21 = new Line(a3, a4);
            line21.Layer = contour;
            line21.Lineweight = Lineweight.W50;
            dxf.AddEntity(line21);
            Line line22 = new Line(a5, a6);
            line22.Layer = contour;
            line22.Lineweight = Lineweight.W50;
            dxf.AddEntity(line22);
            Line line23 = new Line(a6, a7);
            line23.Layer = contour;
            line23.Lineweight = Lineweight.W50;
            dxf.AddEntity(line23);
            Line line24 = new Line(a7, a8);
            line24.Layer = contour;
            line24.Lineweight = Lineweight.W50;
            dxf.AddEntity(line24);
            Line line25 = new Line(a9, a10);
            line25.Layer = contour;
            line25.Lineweight = Lineweight.W50;
            dxf.AddEntity(line25);
            Line line26 = new Line(a10, a11);
            line26.Layer = contour;
            line26.Lineweight = Lineweight.W50;
            dxf.AddEntity(line26);
            Line line27 = new Line(a11, a12);
            line27.Layer = contour;
            line27.Lineweight = Lineweight.W50;
            dxf.AddEntity(line27);
            Line line28 = new Line(a13, a14);
            line28.Layer = contour;
            line28.Lineweight = Lineweight.W50;
            dxf.AddEntity(line28);
            Line line29 = new Line(a15, a16);
            line29.Layer = contour;
            line29.Lineweight = Lineweight.W50;
            dxf.AddEntity(line29);
            Line line30 = new Line(a10, a17);
            line30.Layer = contour;
            line30.Lineweight = Lineweight.W50;
            dxf.AddEntity(line30);
            Line line31 = new Line(a18, a19);
            line31.Layer = contour;
            line31.Lineweight = Lineweight.W50;
            dxf.AddEntity(line31);
            Line line32 = new Line(a20, a21);
            line32.Layer = contour;
            line32.Lineweight = Lineweight.W50;
            //dxf.AddEntity(line32);
            Line line33 = new Line(a21, a22);
            line33.Layer = contour;
            line33.Lineweight = Lineweight.W50;
            dxf.AddEntity(line33);
            Ellipse ellipse1 = new Ellipse(a23, 1, 0.5);
            ellipse1.Layer = contour;
            ellipse1.Lineweight = Lineweight.W50;
            dxf.AddEntity(ellipse1);
            Ellipse ellipse2 = new Ellipse(a24, 1, 0.5);
            ellipse2.Layer = contour;
            ellipse2.Lineweight = Lineweight.W50;
            dxf.AddEntity(ellipse2);
            Line line34 = new Line(a25, a26);
            line34.Layer = contour;
            line34.Lineweight = Lineweight.W25;
            dxf.AddEntity(line34);
            Line line35 = new Line(a27, a28);
            line35.Layer = contour;
            line35.Lineweight = Lineweight.W25;
            dxf.AddEntity(line35);
            Line line2 = new Line(a29, a30);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.Center;
            dxf.AddEntity(line2);
            Line line3 = new Line(a31, a32);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.Center;
            dxf.AddEntity(line3);

            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(a5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(a8));
            hatchpoly1.Vertexes[0].Bulge = Math.Tan(17 * pi / 180 / 4);
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(a7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(a6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(a5));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);

         

            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(a9));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(a12));
            hatchpoly2.Vertexes[0].Bulge = Math.Tan(17 * pi / 180 / 4);
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(a11));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(a10));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(a5));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 1, hline2, harc2, hatching);


            //标注
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 10;
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(a31, a33), new Line(a27, a28), offset * 3, dimensionStyle);
            angdim1.UserText = "DRVA";
            dxf.AddEntity(angdim1);




            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
      
    }
}
